package com.vpx.server.service.system.impl;

import com.vpx.server.mapper.system.SqlMapper;
import com.vpx.server.service.system.SqlExtService;
import com.vpx.server.service.system.SqlService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class SqlExtServiceImpl implements SqlExtService {

    @Resource
    SqlService sqlService;
    @Resource
    SqlMapper  sqlMapper;
    @Override
    public int execute(String sql) {
        return  sqlMapper.executeSql(sql);
    }

    @Override
    public <T> T findOne(String sql, Class<T> resultType) {
        Map<String,Object> param = new HashMap<>();
        param.put("queryBySql",sql);
        return sqlService.findOne("", param, resultType);
    }

    @Override
    public <T> List<T> findList(String sql, Class<T> resultType) {
        Map<String,Object> param = new HashMap<>();
        param.put("queryBySql",sql);
        return sqlService.findList("", param, resultType);
    }

    @Override
    public <T> T findOneObject(String sql, Class<T> resultType) {
        Map<String,Object> param = new HashMap<>();
        param.put("queryBySql",sql);
        return sqlService.findOneObject("", param, resultType);
    }

    @Override
    public <T> List<T> findListObject(String sql, Class<T> resultType) {
        Map<String,Object> param = new HashMap<>();
        param.put("queryBySql",sql);
        return sqlService.findListObject("", param, resultType);
    }
}
